<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Http\Server\LoginServer;
use App\Http\Server\WechatServer;
use App\Models\User;
use App\Services\JsonResponseService;
use Illuminate\Http\Request;
use EasyWeChat\Factory;
use Illuminate\Support\Facades\Redis;

class LoginController extends Controller
{
    public function __construct() {
        $this->server = new LoginServer();
    }



    public function login(Request $request)
    {
        $code = $request->input('code');
        $res = $this->server->loginServer($code);
        return JsonResponseService::success($res['data'],$res['msg'],$res['code']);
    }

    public function getUserInfoByToken(Request $request){
        $token = $request->input('token')??$request->header('token');
        $res = (new LoginServer())->getUserInfoByToken($token);
        return JsonResponseService::success($res,'success',200);
    }
}
